package servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bean.Online;
import deo.touyundeo;

public class TouyunServlet extends HttpServlet{
	public void doGet(HttpServletRequest request, HttpServletResponse response)  
            throws ServletException, IOException {  
  
        this.doPost(request, response);  
    }  
  
    public void doPost(HttpServletRequest request, HttpServletResponse response)  
            throws ServletException, IOException {  
  
    	touyundeo db = new touyundeo();  
        String sql = " select a.area,a.company_num,a.monitor_num,a.online_num,a.offline_num,a.online_rate,b.online_rate "
        		+ "from (select * from online where  equ_date='2017-05-09') a,(select * from online where  equ_date='2017-05-08') b "
        		+ "where a.area=b.area"; 
        
        ArrayList<Online> list = null;
		try {
			list = db.getTouyunList(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		}
        request.setAttribute("list", list);  
        
        request.getRequestDispatcher("touyun.jsp").forward(request, response);  
    }  
}
